package com.gitee.ywj1352.learning.ag.uc.controller;

import com.gitee.ywj1352.learning.ag.uc.biz.BaseUserBiz;
import com.gitee.ywj1352.learning.ag.uc.entity.BaseUser;
import com.gitee.ywj1352.learning.ag.uc.entity.ResponseVO;
import com.gitee.ywj1352.lerning.ag.common.exception.BaseException;
import com.gitee.ywj1352.lerning.ag.common.rest.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * Created by ywj on 2018/2/6.
 */
@RestController
public class UserController extends BaseController<BaseUserBiz,BaseUser>{
    @Value("${user.name}")
    private String name;

    @Autowired
    private BaseUserBiz baseUserBiz;

    @GetMapping("/user/{id}")
    public ResponseVO getUserById(@PathVariable Long id){
        return new ResponseVO(baseUserBiz.selectByPrimaryKey(id));
    }

    @PostMapping("/user")
    public ResponseVO insertUser(@RequestBody BaseUser baseUser) throws BaseException {
        baseUserBiz.insert(baseUser);
        return new ResponseVO();
    }
}
